/*
 * @Author: your name
 * @Date: 2021-04-17 13:27:51
 * @LastEditTime: 2021-04-19 08:42:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-xmall\src\api\index.js
 */
import Ajax from '@/api/ajax'
//获取导航数据
export const reqNavList = () => {
  return Ajax({
    url: '/navlist',
    method: 'get'
  })
}
// 请求全部商品数据
export const reqAllGoodsData = () => {
  return Ajax({
    url: '/allgoods',
    method: 'get'
  })
}
//请求订单支付界面
export const reqPayInfo = (orderId) => {
  return Ajax({
    url: `/orderdetail/${orderId}`,
    method: 'get'
  })
}
// 请求支付信息
export const reqPaySuccess = (orderId) => {
  return Ajax({
    url: `/orderList/${orderId}`,
    method: 'get'
  })
}
// 商品详情
export const getProductDetail = (productId) => {
  return Ajax({
    url: `/product/${productId}`,
    method: 'get'

  })
}
export const deteleProduct = (goodsId) => {
  return Ajax({
    url: `/product/${goodsId}`,
    method: 'delete'
  })
}
//根据token获取用户信息
export const reqUserInfo = () => {
  return Ajax({
    url: `/userInfo`,
    method: 'get'
  })
}
//获取验证码
export const reqPhoneCode = () => {
  return Ajax({
    url: '/getCode',
    method: 'get'
  })
}
//获取轮播图数据
export const reqSwiperList = () => {
  return Ajax({
    url: '/home',
    method: 'get'
  })
}
//获取购物车列表
export const reqCartList = (userId) => {
  return Ajax({
    url: `/cartList/${userId}`,
    method: 'get'
  })
}
//添加购物车
export const reqAddShopCart = (productId, productNum) => {
  return Ajax({
    url: `/addshopcart/${productId}/${productNum}`,
    method: 'get'
  })
}
//修改选中状态
export const reqChangeChecked = (productId, checked) => {
  return Ajax({
    url: `/cart/checkCart/${productId}/${checked}`,
    method: 'get'
  })
}
//删除单个购物车
export const reqDeleteOneCart = (productId) => {
  return Ajax({
    url: `/cart/deleteOneCart/${productId}`,
    method: 'delete'
  })
}
//全选/全不选
export const reqChangeAllChecked = (checked) => {
  return Ajax({
    url: `/cart/changeAllChecked/${checked}`,
    method: 'get'
  })
}
export const getAddress = (addressId) => {
  return Ajax({
    url: `/address/${addressId}`,
    method: 'get'
  })
}

export const reqCode = () => {
  return Ajax({
    url: '/api/user/passport/code',
    method: 'get'
  })
}
//请求token
export const reqToken = (phone, password) => {
  return Ajax({
    url: `/checkLogin?phone=${phone}&password=${password}`,
    method: 'get'
  })
}



// 捐赠名单数据
export const reqDonationList = () => {
  return Ajax({
    url: '/donation',
    method: 'get'
  })
}

// 捐赠页列表
export const reqThankList = () => {
  return Ajax({
    url: '/thank',
    method: 'get'
  })
}
